from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver=webdriver.Firefox()
sleep(2)
driver.get("http://baidu.com")
sleep(2)
#元素定位
#id
# driver.find_element("id","kw").send_keys("赵云")
#name
# driver.find_element(By.NAME,"wd").send_keys("甘肃炎阳")
#class_name
# driver.find_element(By.CLASS_NAME,"s_ipt").send_keys("赵子龙")
#tag_name
# driver.find_element(By.TAG_NAME,"input").send_keys("哪吒")
# link_text
# driver.find_element(By.LINK_TEXT,"hao123").click()
# part_link
# driver.find_element(By.PARTIAL_LINK_TEXT,"新").click()
# xpath路径
# driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div[3]/a[1]').click()
#css选择器
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("hello")
# sleep(5)
# driver.quit()
#操作命令
#清除clear
# driver.find_element(By.ID,"kw").clear()
#点击 submit()
# driver.find_element(By.CSS_SELECTOR,"#su").submit()
#size 尺寸
# print(driver.find_element(By.CSS_SELECTOR,"#su").size)
#text 属性
# aa=driver.find_element(By.LINK_TEXT,"新闻").text
#get_attribute() 获取属性值
# aa=driver.find_element(By.ID,"su").get_attribute("value")
# print(aa)

#设置浏览器大小
# driver.set_window_size(500,500)
#最大化
# driver.maximize_window()
#最小化
# driver.minimize_window()
# 前进和后退
# driver.find_element(By.ID,"kw").send_keys()
# driver.find_element(By.ID,"su").click()
# driver.back()
# driver.forward()
#标题，网址
# print(driver.title)
# print(driver.current_url)
# #close 关闭当前页面 quit 浏览器
# driver.close()
driver.quit()